import 'package:winkai/generated/json/base/json_convert_content.dart';
import 'package:winkai/entity/user_info.dart';

UserInfo $UserInfoFromJson(Map<String, dynamic> json) {
  final UserInfo userInfo = UserInfo();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userInfo.id = id;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    userInfo.nickname = nickname;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userInfo.avatar = avatar;
  }
  final String? deviceId = jsonConvert.convert<String>(json['device_id']);
  if (deviceId != null) {
    userInfo.deviceId = deviceId;
  }
  final String? token = jsonConvert.convert<String>(json['token']);
  if (token != null) {
    userInfo.token = token;
  }
  return userInfo;
}

Map<String, dynamic> $UserInfoToJson(UserInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['nickname'] = entity.nickname;
  data['avatar'] = entity.avatar;
  data['device_id'] = entity.deviceId;
  data['token'] = entity.token;
  return data;
}

extension UserInfoExtension on UserInfo {
  UserInfo copyWith({
    String? id,
    String? nickname,
    String? avatar,
    String? deviceId,
    String? token,
  }) {
    return UserInfo()
      ..id = id ?? this.id
      ..nickname = nickname ?? this.nickname
      ..avatar = avatar ?? this.avatar
      ..deviceId = deviceId ?? this.deviceId
      ..token = token ?? this.token;
  }
}